//
//  SLShareAlertView.m
//  SlockApp
//
//  Created by 凯朱 on 2024/7/30.
//

#import "SLShareAlertView.h"

@implementation SLShareAlertView
-(void)awakeFromNib{
    [super awakeFromNib];
    _list.layer.cornerRadius = 2;
    _list.layer.masksToBounds = YES;
    _titleLbl.text = kLocalString(@"Share this access");
    
    _contentLbl.text = kLocalString(@"Please provide the link to your guest, They will need to download the HEXFORCE app to redeem the key.");
    _tipLbl.text = kLocalString(@"This link will expries in 2 days.");
    
    _shareBtn.btnStyle = 1;
    [_shareBtn setTitle:kLocalString(@"Share") forState:UIControlStateNormal];
    [_skipBtn setTitle:kLocalString(@"Skip") forState:UIControlStateNormal];
    
    _linkBgView.layer.cornerRadius = 20;
    _linkBgView.layer.masksToBounds = YES;
    
    _bgView.layer.cornerRadius = 10;
    _bgView.layer.masksToBounds = YES;
    
    kWeakSelf(self);
    _grayView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [weakself removeWithAnimation];
    }];
    [_grayView addGestureRecognizer:tap];
    
    _hideView.userInteractionEnabled = YES;
    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeDown:)];
    swipeRight.direction = UISwipeGestureRecognizerDirectionDown;
    [_hideView addGestureRecognizer:swipeRight];
}

// 手势处理方法
- (void)handleSwipeDown:(UISwipeGestureRecognizer *)gesture {
    if (self.btnBlock) self.btnBlock(2);
}

- (IBAction)btnAction:(id)sender {
    if (sender == _shareBtn) {
        if (self.btnBlock) self.btnBlock(1);
    }else if (sender == _skipBtn){
        if (self.btnBlock) self.btnBlock(2);
    }else if (sender == _copBtn){
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.string = _linkLbl.text;
        kShowToast(kLocalString(@"Copy Success!"));
    }
}

@end
